package day0411;

/**
 * @author zhoujunjie
 * @desc TODO
 * @date 2025/4/11
 */
public class Test01 {
    public static void main(String[] args) {
        int[] arr = {10, 22, 3, 41, 15, 6, 71, 18, 39};
        int n = arr.length;
        boolean swapped;
        for (int i = 0; i < n; i++) {
            swapped = false;
            for (int j = 0; j < n - i - 1; j++) {
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                    swapped = true;
                }
            }
            for (int a : arr) {
                System.out.print(a + " ");
            }
            System.out.println();
            if (!swapped) {
                break;
            }
        }
    }
}